package com.example.enterprise.vm

import com.example.common.view.vm.BaseViewModel
import com.example.enterprise.api.EnterpriseApiService
import com.example.enterprise.entity.HouseEntityItem
import com.example.enterprise.model.EnterpriseRepository
import com.example.enterprise.model.EnterpriseResultData
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.launch
import javax.inject.Inject

@HiltViewModel
class EnterpriseAddViewModel @Inject constructor(private val apiService: EnterpriseApiService):BaseViewModel<EnterpriseRepository,EnterpriseResultData<HouseEntityItem>>(){
    fun postMerchant(houseEntityItem:HouseEntityItem){
        mViewModelScope.launch (mDispatcher){
            try {
                val result = apiService.postMerchant(houseEntityItem)
                mSuccessLiveData.postValue(result)
            } catch (e:Exception){
                mErrorLiveData.postValue("请求失败:${e.message}")
            }
        }
    }
}